#!/bin/bash

set -o errexit

echo please sudo now so that installs work
sudo id

sudo apt-get install \
    build-essential imagemagick scons mercurial \
    libpng12-dev libjpeg8-dev libtiff4-dev libgif-dev \
    libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl1.2-dev \
    libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
    libavfilter-dev \
    libpng12-dev libjpeg8-dev libtiff4-dev libgif-dev \
    libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl1.2-dev \
    libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
    libavfilter-dev \
    libgsl0-dev libblas-dev \
    libsqlite3-dev\
    liblapack-dev libatlas-base-dev \
    python-dev swig2.0 swig zlib1g-dev \
    python-scipy python-matplotlib python-matplotlib-data \
    python-sklearn \
    python-tables \
    ipython curl cmake

(
cd ocropy
(cd models; ./ocropus-download)
sudo python setup.py install
cd ..
date;
)

(
cd llpy
sudo python setup.py install
cd ..
date;
)

(
sudo rm -rf flann-1.7.1-src
unzip DIST/flann-1.7.1-src.zip
cd flann-1.7.1-src
rm -rf build
mkdir build
cd build
cmake .. -DBUILD_MATLAB_BINDINGS=OFF
make
sudo make install
)

(echo $LD_LIBRARY_PATH | grep /usr/local/lib) || {
        echo
        echo IMPORTANT
        echo
        echo You must add /usr/local/lib/ to your LD_LIBRARY_PATH variable 
        echo and add /usr/local/bin to your PATH variable.
        echo
}

